# coding=utf-8
import re

rule_dic = {
    "page" : r"https://www.douban.com/group/explore/\s+",
    "topic" : r"https://www.douban.com/group/topic/\d+/",
    "group" : r"https://www.douban.com/group/\d+/\?ref=sidebar",
    "comment": r"https://www.douban.com/group/topic/\d+/?start=\d+"
}


def page_process_value(value):
    return process_value(rule_dic["page"], value)

def topic_process_value(value):
    return process_value(rule_dic["topic"], value)

def group_process_value(value):
    return process_value(rule_dic["group"], value)

def comment_process_value(value):
    return process_value(rule_dic["comment"], value)

def process_value(regex ,value) :
    pattern = re.compile(regex)
    m = pattern.match(value)
    if m:
        return m.group()

